package com.wens.baselibrary.view.dialog;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.wens.baselibrary.R;

import org.jetbrains.annotations.NotNull;

public class BackDialog extends BaseDialog {
    private View.OnClickListener okClickListener;
    private View.OnClickListener cancelClickListener;
    private TextView message;


    public BackDialog(@NotNull Activity activity) {
        super(activity, R.layout.back_dialog);
    }

    public BackDialog setOkClickListener(View.OnClickListener okClickListener) {
        this.okClickListener = okClickListener;
        return this;
    }

    public BackDialog setCancelClickListener(View.OnClickListener cancelClickListener) {
        this.cancelClickListener = cancelClickListener;
        return this;
    }

    @Override
    protected void initView(View view) {
        message = view.findViewById(R.id.message);
        view.findViewById(R.id.btnOk).setOnClickListener(v -> {
            okClickListener.onClick(v);
            dismiss();
        });

        view.findViewById(R.id.btnCancel).setOnClickListener(v -> {
            cancelClickListener.onClick(v);
            dismiss();
        });
    }

    public BackDialog setMessage(String message) {
        this.message.setText(message);
        return this;
    }

    public BaseDialog setMessage(int id) {
        message.setText(id);
        return this;
    }
}
